<template>
  <div>
    <el-dialog
      :title="liulanchildren.trialTypeName"
      :visible.sync="dialogVisible"
      width="60%"
      center>
      <div>
        <div class="shangxia" ref="shangxia" >
          <el-form :model=zibaogaoform label-position="right" label-width="100">
              <div class="twobox" >
                <div class="texth">基本信息</div>
                <div  class="clearfix" style="padding: 10px;">
                  <el-col :span="8" v-for="(itemthree,indexthree) in formlist" :key="indexthree" >
                    <el-form-item :label="itemthree.trialProjectName" >
                      <el-input v-if="itemthree.dataType!=='2'&&itemthree.dataType!=='3'&&itemthree.dataType!=='4'" v-model="itemthree.value" :placeholder="`请输入${itemthree.trialProjectName}`" style="width: 100%;" size="small">
                        <span slot="suffix">{{ itemthree.unit }}</span>
                      </el-input>
                      <el-input v-else v-model="itemthree.convertValue" :placeholder="`请输入${itemthree.trialProjectName}`" style="width: 100%;" size="small">
                        <span slot="suffix">{{ itemthree.unit }}</span>
                      </el-input>
                    </el-form-item>
                  </el-col>
                </div>
                <div class="texth">使用设备及型号</div>
                <div class="shiyongshebei">
                  <div class="headerbox">
                    <div class="headerlitts">名称</div>
                    <div class="headerlitt">型号</div>
                    <div class="headerlitt" style="border-right: none;">制造厂商</div>
                  </div>
                  <div class="bodybox">
                     <div class="boleftbox">
                       <div class="leftlitt" style="border-top: none;">绝缘电阻测试仪</div>
                       <div class="leftlitt">交流耐压测试仪</div>
                       <div class="leftlitt">断路器机械特性测试仪</div>
                       <div class="leftlitt">回路电阻测试仪</div>
                     </div>
                     <div class="xunhuand">
                        <div class="lilllebox" v-for="(item,index) in ceshiyilist" :key="index">{{item.value}}</div>
                     </div>
                  </div>
                </div>
                <div class="texth">试验数据</div>
                <div class="shiyanshujuone">
                   <div class="shujuoneheder">
                    <div class="shujuonelittle">项目/相别</div>
                    <div class="shujuonelittle">接触电阻(UΩ)</div>
                    <div class="shujuonelittle">绝缘电阻</div>
                    <div class="shujuonelittle">整体交流耐压</div>
                    <div class="shujuonelittle" style="border-right: none;">断口交流耐压</div>
                   </div>
                   <div class="shujuonebody">
                     <div class="shujuoneleft">
                       <div class="shujuoneli">A</div>
                       <div class="shujuoneli">B</div>
                       <div class="shujuoneli">C</div>
                     </div>
                     <div class="shujuonexunhuan">
                       <div class="xunhuanlittle" v-for="(item,index) in shiyanonelist" :key="index">{{ item.value }}</div>
                     </div>
                   </div>
                </div>
                <div class="shiyanshujuone">
                   <div class="shujuoneheder">
                    <div class="shujuonelittle">线圈</div>
                    <div class="shujuonelittle">直流电阻(Ω)</div>
                    <div class="shujuonelittle">绝缘电阻(MΩ)</div>
                    <div class="shujuonelittle">最低电压(V)</div>
                    <div class="shujuonelittle" style="border-right: none;">30%电压下</div>
                   </div>
                   <div class="shujuonebody">
                     <div class="shujuoneleft">
                       <div class="shujuoneli">合闸线圈</div>
                       <div class="shujuoneli">分闸线圈</div>
                     </div>
                     <div class="shujuonexunhuan">
                       <div class="xunhuanlittle" v-for="(item,index) in shiyantwolist" :key="index">{{ item.value }}</div>
                     </div>
                   </div>
                </div>
                <div class="dongzuotime">
                  <div class="dongzuotopbox">
                    <div class="dongzuoleftbo">
                      <div class="litttop"></div>
                      <div class="littlebo">
                        <div class="littlebodyleft">动作时间</div>
                        <div class="littlebodyrig">
                          <div class="littlehe">合闸(ms)</div>
                          <div class="littlehe">分闸(ms)</div>
                        </div>
                      </div>
                      <div class="littlefooter">弹跳时间(ms)</div>
                    </div>
                    <div class="dongzuori">
                      <div class="dongzuorightheader">
                        <div class="dongzuorighthtaderlitt">A</div>
                        <div class="dongzuorighthtaderlitt">B</div>
                        <div class="dongzuorighthtaderlitt">C</div>
                      </div>
                      <div class="dongzuoxunhuan">
                        <div class="dongzuoxunhuanlittle" v-for="(item,index) in dongzuolist" :key="index">{{ item.value }}</div>
                      </div>
                    </div>
                  </div>
                  <div class="donzuobutongqi">
                     <div class="butongqi">三相不同期</div>
                     <div class="fenorhe">合闸(ms):{{ butongqilist[0]?.value }}</div>
                     <div class="fenorhe">分闸(ms):{{ butongqilist[1]?.value }}</div>
                  </div>
                </div>
             </div>
             <div class="foorterxunhuan">
                  <el-col :span="12" v-for="(item,index) in forterlist" :key="index">
                    <el-form-item :label="item.trialProjectName">
                      <el-input v-if="item.dataType!=='2'&&item.dataType!=='3'&&item.dataType!=='4'" v-model="item.value" style="width: 100%;" :placeholder="`请输入${item.trialProjectName}`"  size="small"></el-input>
                      <el-input v-else v-model="item.convertValue" style="width: 100%;" :placeholder="`请输入${item.trialProjectName}`"  size="small"></el-input>
                    </el-form-item>
                  </el-col>
                </div>
          </el-form>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" size="small">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getchushihuazibaogaoapi } from '@/api/Experimental-report/Main-information'
import {setlistsort} from '@/utils/array'
export default {
  name: 'CallPoliceChildrenVacuum',

  props: {
    liulanchildren: {
      type:Object
    },
    orgNo: {
      type:String
    }
  },
  data() {
    return {
      zibaogaoform:{},
      formlist:[],
      dialogVisible: false,
      forterlist: [],
      ceshiyilist:[],
      shiyanonelist:[],
      shiyantwolist: [],
      dongzuolist: [],
      butongqilist:[]
    };
  },

  mounted() {
    
  },

  methods: {
    
  },
  watch: {
    async dialogVisible(val) {
      if (val) {
        const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        target: this.$refs.shangxia
      });
        const { data: { list } } = await getchushihuazibaogaoapi({ id: this.liulanchildren.id, orgNo: this.orgNo, trialType: this.liulanchildren.trialType })
        this.formlist = list[0].children[0].children
        let arr1 = []
        for (let i = 0; i < list.length; i++){
          if (list[i].text == '试验仪器') {
             this.ceshiyilist=list[i].children[0].children
          }
          for (let j = 0; j < list[i].children.length; j++){
            for (let k = 0; k < list[i].children[j].children.length; k++) { 
              arr1.push(list[i].children[j].children[k])
              if (list[i].children[j].text=='合闸线圈'||list[i].children[j].text=='分闸线圈') {
               this.shiyantwolist.push(list[i].children[j].children[k])
              }
            }
          }
        }
        let arr3 = ['结论', '备注', '试验员', '审核人', '批准人']
        const arr4 = arr1.filter(ele => { 
          for (let i = 0; i < arr3.length; i++){
             if(ele.trialProjectName==arr3[i]){
              return ele
             }
          }
        })
        this.forterlist = arr4

        let shiyanone=['A相接触电阻','A相绝缘电阻','一分钟整体交流耐压','一分钟断口交流耐压','B相接触电阻','B相绝缘电阻','C相接触电阻','C相绝缘电阻',]
        let shionelist = arr1.filter(ele => {
          for (let i = 0; i < shiyanone.length; i++){
            if(ele.trialProjectName==shiyanone[i]){
              return ele
           }
          }
        })
        const shiarr= setlistsort(shionelist,shiyanone)
        shiarr.splice(6, 0, {'value':'-'});
        shiarr.splice(7, 0, {'value':'-'});
        shiarr.splice(10, 0, {'value':'-'});
        shiarr.splice(11, 0, { 'value': '-' });
        this.shiyanonelist = shiarr

        const dongzuo=['A相合闸动作时间','B相合闸动作时间','C相合闸动作时间','A相分闸动作时间','B相分闸动作时间','C相分闸动作时间','A相弹跳时间','B相弹跳时间','C相弹跳时间',]
        const butongqi=['三相不同期合闸','三相不同期分闸']
        let dongarr=arr1.filter(ele => {
          for (let i = 0; i < dongzuo.length; i++){
            if(ele.trialProjectName==dongzuo[i]){
              return ele
           }
          }
        })
        this.dongzuolist = setlistsort(dongarr, dongzuo)
        let butong=arr1.filter(ele => {
          for (let i = 0; i < butongqi.length; i++){
            if(ele.trialProjectName==butongqi[i]){
              return ele
           }
          }
        })
        this.butongqilist = setlistsort(butong, butongqi)
        loading.close();
      }
    }
  }
};
</script>

<style scoped>
.shangxia{
      height: 500px;
      overflow: auto;
      border-bottom: 1px solid #ccc;
      .foorterxunhuan{
              margin-top: 30px;
              width: 100%;
              display: flex;
              flex-wrap: wrap;
               ::v-deep .el-form-item__label{
                font-size: 18px;
                  color: #323232;
                  font-weight: bold;
               }
              .inputbox{
                margin-bottom: 20px;
                width: 40%;
                .text{
                  font-size: 18px;
                  color: #323232;
                  font-weight: bold;
                }
              }
            }
      .twobox{
        padding: 15px 0;
        .texth{
              font-size: 18px;
              font-weight: bold;
              color: #323232;
            }
            .shiyongshebei{
              margin: 20px 0;
               width: 100%;
               border: 1px solid #ccc;
               border-bottom: none;
               .headerbox{
                display: flex;
                background-color: #f1f1f1;
                border-bottom: 1px solid #ccc;
                .headerlitt{
                  width: 33%;
                  text-align: center;
                  height: 50px;
                  line-height: 50px;
                  border-right: 1px solid #ccc;
                }
                .headerlitts{
                  width: 34%;
                  text-align: center;
                  height: 50px;
                  line-height: 50px;
                  border-right: 1px solid #ccc;
                }
               }
               .bodybox{
                 display: flex;
                 .boleftbox{
                  width: 34%;
                  background-color: #f1f1f1;
                  border-bottom: 1px solid #ccc;
                  .leftlitt{
                    height: 50px;
                    line-height: 50px;
                    text-align: center;
                    border-top: 1px solid #ccc;
                  }
                  /* .leftlitts{
                    width: 34%;
                  } */
                 }
                 .xunhuand{
                  flex: 1;
                  display: flex;
                  flex-wrap: wrap;
                  .lilllebox{
                    width: 50%;
                    height: 50px;
                    line-height: 50px;
                    text-align: center;
                    border-left: 1px solid #ccc;
                    border-bottom: 1px solid #ccc;
                  }
                 }
               }
            }
            .shiyanshujuone{
              width: 100%;
              margin: 20px 0;
              border: 1px solid #ccc;
              .shujuoneheder{
                display: flex;
                background-color: #f1f1f1;
                .shujuonelittle{
                  width: 20%;
                  height: 50px;
                  line-height: 50px;
                  text-align: center;
                  border-right: 1px solid #ccc;
                }
              }
              .shujuonebody{
                width: 100%;
                display: flex;
                .shujuoneleft{
                  width: 20%;
                  background-color: #f1f1f1;
                  .shujuoneli{
                    height: 50px;
                    line-height: 50px;
                    text-align: center;
                    border-top: 1px solid #ccc;
                  }
                }
                .shujuonexunhuan{
                  flex: 1;
                  display: flex;
                  flex-wrap: wrap;
                  .xunhuanlittle{
                    width: 25%;
                    height: 50px;
                    line-height: 50px;
                    text-align: center;
                    border-top: 1px solid #ccc;
                    border-left: 1px solid #ccc;
                  }

                }
              }
            }
            .dongzuotime{
              width: 100%;
              margin: 20px 0;
              border: 1px solid #ccc;
              .dongzuotopbox{
                display: flex;
                .dongzuoleftbo{
                  width: 40%;
                  background-color: #f1f1f1;
                  .litttop{
                    height: 50px;
                    border-bottom: 1px solid #ccc;
                  }
                  .littlefooter{
                    height: 50px;
                    line-height: 50px;
                    text-align: center;
                    border-bottom: 1px solid #ccc;
                  }
                  .littlebo{
                    display: flex;
                    .littlebodyleft{
                      width: 50%;
                      height: 100px;
                      line-height: 100px;
                      text-align: center;
                      border-bottom: 1px solid #ccc;
                    }
                    .littlebodyrig{
                      width: 50%;
                      .littlehe{
                        height: 50px;
                        line-height: 50px;
                        text-align: center;
                        border-bottom: 1px solid #ccc;
                        border-left: 1px solid #ccc;
                      }
                    }
                  }
                }
                .dongzuori{
                  flex: 1;
                  .dongzuorightheader{
                    background-color: #f1f1f1;
                    display: flex;
                    .dongzuorighthtaderlitt{
                      width: 33.33333%;
                      height: 50px;
                      line-height: 50px;
                      text-align: center;
                      border-left: 1px solid #ccc;
                      border-bottom: 1px solid #ccc;
                    }
                  }
                  .dongzuoxunhuan{
                    display: flex;
                    flex-wrap: wrap;
                    .dongzuoxunhuanlittle{
                      width: 33.33333%;
                      height: 50px;
                      line-height: 50px;
                      text-align: center;
                      border-left: 1px solid #ccc;
                      border-bottom: 1px solid #ccc;
                    }
                  }
                }
              }
              .donzuobutongqi{
                display: flex;
                .butongqi{
                  width: 20%;
                  background-color: #f1f1f1;
                  height: 50px;
                  line-height: 50px;
                  text-align:center;
                }
                .fenorhe{
                  width: 40%;
                  height: 50px;
                  line-height: 50px;
                  text-align:center;
                  border-left: 1px solid #ccc;
                }
              }
            }
        .threebox{
          padding: 10px;
            .bluebgc{
              display: inline-block;
              width: 5px;
              height: 16px;
              background-color: #187cf5;
              margin-right: 10px;
              border-radius: 3px;
              vertical-align: middle;
            }
            .bluetext{
              display: inline-block;
              vertical-align: middle;
              font-size: 18px;
              color: #323232;
            }
        }
      }
    }
.clearfix::after {
  content: "";
  clear: both;
  display: table;
  .bigwaiwei{
    width: 100%;
    .bgc{
      background-color: #f1f1f1;
    }
    .header{
      display: flex;
      .widthfour{
        width: 25%;
        height: 50px;
        text-align: center;
        line-height: 50px;
      }
    }
    .footer{
      display: flex;
      .footleft{
        width: 25%;
      }
    }
  }
}
::v-deep .el-form-item{
  display: flex;
  margin-right: 10px;
}
::v-deep .el-form-item__content{
  flex:1;
}
</style>